﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <link href="../../../Scripts/easyUI145/themes/icon.css" rel="stylesheet" type="text/css" />
    <link href="../../../Scripts/easyUI145/themes/default/easyui.css" rel="stylesheet"
          type="text/css" />
    <link href="../../../../DataUser/Style/ccbpm.css" rel="stylesheet" type="text/css" />
    <script src="../../../Scripts/easyUI145/jquery.min.js" type="text/javascript"></script>
    <script src="../../../Scripts/easyUI145/jquery.easyui.min.js" type="text/javascript"></script>
    <script src="../../../Scripts/QueryString.js" type="text/javascript"></script>
    <script src="../../../Scripts/config.js" type="text/javascript"></script>
    <script src="../../../Comm/JScript.js" type="text/javascript"></script>
    <script src="../../../Scripts/CommonUnite.js" type="text/javascript"></script>
    <script src="../../../Scripts/EasyUIUtility.js" type="text/javascript"></script>
    <script src="../../../Scripts/QueryString.js" type="text/javascript"></script>
    <script src="../../../Comm/Gener.js" type="text/javascript"></script>
    <!-- 自己的系统风格统一. -->
    <link href="../../../Style/skin/adminfont/iconfont.css" rel="stylesheet" />
    <link href="../../../Style/skin/css/Default.css" rel="stylesheet" />
    <!-- 自己的系统风格统一end -->
    <script src="DDLBar.js" type="text/javascript"></script>
    <script src="../../CCFlowEnum.js" type="text/javascript"></script>
    <script type="text/javascript">

        var nodeID = 0;
        var fk_flow = "";
        $(function () {

            InitBar(FormSlnType.FoolTruck);

            Sln(); //设置权限控制方案.

        });

        //权限控制方案.
        function Sln() {

            var nodeID = GetQueryString("FK_Node");
            var node = new Entity("BP.WF.Node", nodeID);
            if (node.FormType != FormSlnType.FoolTruck)
                return;

            $("#sln").html("正在加载表单方案,请稍后...");

            var html = "<ul>";

            //获得节点.
            var nodes = new Entities("BP.WF.Template.NodeSimples");
            nodes.Retrieve("FK_Flow", node.FK_Flow, "NodeID");
            var currentNode = GetQueryString("FK_Node");

            for (var i = 0; i < nodes.length; i++) {

                var json = nodes[i];
                if (json.NodeID == nodeID)
                    continue;

                var sln = new Entity("BP.WF.Template.FoolTruckNodeFrm");
                sln.MyPK = "ND" + json.NodeID + "_" + currentNode + "_" + json.FK_Flow;

                if (sln.RetrieveFromDBSources() == 0) {
                    sln.FK_Flow = json.FK_Flow;
                    sln.FK_Frm = "ND" + json.NodeID;
                    sln.FK_Node = currentNode; //节点ID.
                    sln.FrmSln = 1; //只读方案.
                    sln.Insert();
                }


                if (sln.FrmSln == 0) {
                    html += "<li>[默认]<a href=\"javascript:EditSln('" + sln.MyPK + "')\">" + json.NodeID + " - " + json.Name + "</a></li>";
                    continue;
                }
                if (sln.FrmSln == 1) {
                    html += "<li>[只读]<a href=\"javascript:EditSln('" + sln.MyPK + "')\">" + json.NodeID + " - " + json.Name + "</a></li>";
                    continue;
                }

                var def = "";

                def = " - <a href=\"javascript:DefField('" + json.NodeID + "','" + json.FK_Flow + "')\" >定义字段权限</a>";
                def += " - <a href=\"javascript:DefAth('" + json.NodeID + "')\" >附件权限</a>";
                def += " - <a href=\"javascript:DefDtl('" + json.NodeID + "')\" >从表权限</a>";

                html += "<li>[" + sln.FrmSlnText + "]<a href=\"javascript:EditSln('" + sln.MyPK + "')\">" + json.NodeID + " - " + json.Name + "</a> " + def + "</li>";
            }
            html += "</ul>";
            $("#sln").html(html);
        }
        function DefField(nodeID, FK_Flow) {
            var url = " ../../Sln/Fields.htm?FK_MapData=ND" + nodeID + "&FK_Node=" + GetQueryString("FK_Node") + "&FK_Flow=" + FK_Flow + "&DoType=Field";
            window.open(url);
        }
        function DefDtl(nodeID) {
            //获取NodeID的的附件权限
            var FK_MapData = "ND" + nodeID;
            var mapDtls = new Entities("BP.Sys.MapDtls");
            mapDtls.Retrieve("FK_MapData", FK_MapData, "FK_Node", 0);
            if (mapDtls.length == 0) {
                alert('当前节点表单没有从表。');
                return;
            }
            if (mapDtls.length != 1) {
                alert("未涉及到两个从表的情况.");
                return;
            }

            var mapDtl = mapDtls[0];
            var currNodeID = GetQueryString("FK_Node");

            //设置当前节点从表权限
            var mypk = mapDtl.No + '_' + currNodeID;
            var mapDtlSln = new Entity("BP.WF.Template.Frm.MapDtlExt");
            mapDtlSln.SetPKVal(mypk);
            if (mapDtlSln.RetrieveFromDBSources() == 0) {
                mapDtlSln.CopyJSON(mapDtl);
                mapDtlSln.No = mypk;
                mapDtlSln.FK_Node = currNodeID;
                mapDtlSln.FK_MapData = "ND" + nodeID;
                mapDtlSln.DirectInsert(); //直接插入，不生成新的分组
                mapDtlSln.DoMethodReturnString("InitAttrsOfSelf");

            }
            var url = "../../FoolFormDesigner/MapDefDtlFreeFrm.htm?FK_MapData=" + mapDtlSln.FK_MapData + "&FK_MapDtl=" + mypk + "&FK_Node=" + currNodeID;
            WinOpen(url);

        }
        function DefAth(nodeID) {
            var currNodeID = GetQueryString("FK_Node");

            //获取NodeID的的附件权限
            var FK_MapData = "ND" + nodeID;
            var aths = new Entities("BP.Sys.FrmAttachments");
            aths.Retrieve("FK_MapData", FK_MapData, "FK_Node", 0);
            if (aths.length == 0) {
                alert('当前节点表单没有附件。');
                return;
            }

            var idx = -1;
            if (aths.length != 1) {

                for (var i = 0; i < aths.length; i++) {
                    var ath = aths[i];

                    var bool = window.confirm('设置附件[' + ath.Name + ']?');
                    if (bool == false)
                        continue;

                    idx = i;
                }

                if (idx == -1)
                    return;
            }

            if (idx == -1)
                idx = 0;

            var ath = aths[idx];

            //设置当前节点的附件权限
            var athSln = new Entity("BP.Sys.FrmAttachment");
            athSln.MyPK = ath.MyPK + "_" + currNodeID;
            athSln.SetPKVal = athSln.MyPK;
            if (athSln.IsExits() == false) {
                athSln.CopyJSON(ath);
                athSln.FK_MapData = athSln.FK_MapData;
                athSln.MyPK = ath.FK_MapData + "_" + ath.NoOfObj + "_" + currNodeID;
                athSln.FK_Node = currNodeID;
                athSln.CtrlWay = 4;
                athSln.SetPKVal = athSln.MyPK;
                athSln.DirectInsert();

                //athSln.Insert(); //插入新的.
            }

            var url = "../../../Comm/EnOnly.htm?EnName=BP.Sys.FrmUI.FrmAttachmentExt&MyPK=" + athSln.MyPK;
            OpenEasyUiDialog(url, "eudlgframe", '附件权限', 600, 500, "icon-property", true, null, null, null, function () {
                // Reload();
            });

        }
        function EditSln(mypk) {

            var url = "../../../Comm/EnOnly.htm?EnName=BP.WF.Template.FoolTruckNodeFrm&MyPK=" + mypk;

            OpenEasyUiDialog(url, "eudlgframe", '表单方案', 600, 300, "icon-property", true, null, null, null, function () {
                Reload();
            });
        }

        function Save() {
            $("#Btn_Save").html("正在保存...");
            var nodeID = GetQueryString("FK_Node");
            var node = new Entity("BP.WF.Node", nodeID);
            node.FormType = FormSlnType.FoolTruck;
            node.NodeFrmID = "ND" + nodeID;
            node.Update();

            //更新表单类型.
            var frmID = "ND" + nodeID;
            var mapData = new Entity("BP.Sys.MapData", frmID);
            mapData.FrmType = FrmType.FoolForm;
            mapData.Update();


            //执行流程检查.
            var flow = new Entity("BP.WF.Flow", node.FK_Flow);
            flow.DoMethodReturnString("DoCheck");

            $("#Btn_Save").html("保存成功.");
        }


        ///设置该流程的所有节点都是用该方案。
        function SetAllNodeFrmUseThisSln() {

            if (confirm('您确定要设置吗？') == false)
                return;

            var nodeID = GetQueryString("FK_Node");
            var node = new Entity("BP.WF.Node", nodeID);

            var flowNo = node.FK_Flow;
            var nds = new Entities("BP.WF.Nodes");
            nds.Retrieve("FK_Flow", flowNo);

            for (var i = 0; i < nds.length; i++) {

                var jsNode = nds[i];

                var node = new Entity("BP.WF.Node", jsNode);

                node.FormType = FormSlnType.FoolTruck;
                node.NodeFrmID = "ND" + node.NodeID;
                node.Update();

                $.each(nds, function (index, item) {
                    if (node.NodeID != item.NodeID) {
                        var sln = new Entity("BP.WF.Template.FoolTruckNodeFrm");
                        sln.MyPK = "ND" + item.NodeID + "_" + node.NodeID + "_" + node.FK_Flow;

                        if (sln.RetrieveFromDBSources() == 0) {
                            sln.FK_Flow = node.FK_Flow;
                            sln.FK_Frm = "ND" + item.NodeID;
                            sln.FK_Node = node.NodeID; //节点ID.
                            sln.FrmSln = 1; //只读方案.
                            sln.Insert();
                        }
                    }

                })

                //更新表单类型.
                var frmID = "ND" + node.NodeID;
                var mapData = new Entity("BP.Sys.MapData", frmID);
                mapData.FrmType = 0; //FormSlnType.FoolTruck;
                mapData.Update();
            }

            //设置显示的主表单,在完成的流程轨迹里可以看到该表单.
            SetNDxxRpt_FrmType(flowNo, 0);

            //执行流程检查.
            var flow = new Entity("BP.WF.Flow", flowNo);
            flow.DoMethodReturnString("DoCheck");

            alert('设置成功.');
            Reload();
        }
    </script>
</head>
<body>
    <div id="bar">
    </div>

    <fieldset>
        <legend>当前表单权限控制方案</legend>
        <div id="sln">
        </div>
    </fieldset>

    <fieldset>
        <legend>说明</legend>
        <ul>
            <li>该表单是傻瓜表单的一种变形展现方式.</li>
            <li>也叫轨迹表单模式,为软通动力定制的一种表单展示类型.</li>
            <li>适合一个节点一个表单模式,简洁流畅，容易追踪历史运动过程.</li>
            <li> <a href="javascript:DFoolFrm()">设计傻瓜表单</a></li>
            <li>
                <a href="javascript:SetAllNodeFrmUseThisSln()">
                    设置该流程所有的节点都采用此表单方案
                </a>
            </li>
            <li><font color="green"><b>该表单风格可以通过改变\DataUser\Style\ccbpm.css文件改变</b></font></li>
        </ul>
    </fieldset>


    <fieldset>
        <legend id="help"></legend>
        <ul>
            <li>该表单是以傻瓜表单展示，也叫累加表单，也叫轨迹表单。</li>
            <li>每个节点上都有自己的一个字段集合, 当前节点的表单是以前表单按照走过的顺序累加（默认字段只读）加上当前节点表单拼接而成的。</li>
            <li>该表单设计简单，思路清晰，适用于在审核组件模式下不能解决的审核节点特殊字段数据的采集。</li>
            <li>该表单是审核组件模式表单的有益补充。</li>
            <li>PC该表单有4个列,设计简单方便.</li>
            <li><img src='../Img/Col4Frm.JPG' style="width:80%;" class="HelpImg" /> </li>
            <li>PC该表单6列,展示效果</li>
            <li><img src='../Img/Col6Frm.JPG' style="width:80%;" class="HelpImg" /> </li>
            <li>手机端展现有2个列,手机端自动适应,一次性设计</li>
            <li><img src='../Img/Col2Frm.JPG' class="HelpImg" /> </li>
        </ul>
    </fieldset>
</body>
</html>
